<?php

namespace App\Services\MiniprogramToGame\HotSearch;

use App\Services\ServiceBase;
use App\Structs\HotSearchStruct;
use Illuminate\Support\Facades\Http;
use Goutte\Client;

class Hupu extends ServiceBase
{
    public function reptile()
    {
        $client = new Client();
        $crawler = $client->request('GET', 'https://m.hupu.com/hot');

        $list = [];
        $index = 1;
        $topics = $crawler->filter('.hot_hot-page-item__jd5QR')->each(function ($node) use (&$list, &$index) {
            $title = $node->filter('div.hot_hot-page-item-title__HL2kw')->text();
            $hot_value = $node->filter('div.hot_hot-page-item-fire__3aH6N span')->text();

            $class           = new HotSearchStruct;
            $class->title    = $title;
            $class->desc     = $title;
            $class->hotIndex = $index;
            $class->hotValue = $hot_value;
            $class->url = '';
            $list[] = $class;
            $index++;
        });

        return $list;
    }
}
